Page({
  data: {
    wrongQuestions: [],
    showAnalysisMap: {}
  },
  onLoad() {
    const wrongQuestions = wx.getStorageSync('wrongQuestions') || [];
    const showAnalysisMap = {};
    wrongQuestions.forEach(item => {
      showAnalysisMap[item.id] = false;
    });
    this.setData({
      wrongQuestions: wrongQuestions,
      showAnalysisMap: showAnalysisMap
    });
  },
  showAnalysis(e) {
    const id = e.currentTarget.dataset.id;
    const showAnalysisMap = this.data.showAnalysisMap;
    showAnalysisMap[id] = !showAnalysisMap[id];
    this.setData({
      showAnalysisMap: showAnalysisMap
    });
  },
  optionToLetter(index) {
    return String.fromCharCode(65 + index);
  }
});